package com.minimalist.basic.controller.lindi;

import com.minimalist.common.feign.client.lindi.LindiDataviewFeignClient;
import com.minimalist.common.response.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.util.List;
import java.util.Map;

/**
 * 林地指标交易平台_数据可视化控制器
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_数据可视化管理")
@RequestMapping("/basic/lindi/dashboard")
public class LindiDataviewController{

    @Autowired
    private LindiDataviewFeignClient feignClient;

    @GetMapping(value = "/sse/connect", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    @Operation(summary = "建立SSE连接")
    public SseEmitter connect(
            @RequestParam(value = "clientId", required = false) String clientId){
        return feignClient.connect(clientId);
    }

    @PostMapping("/sse/start-push")
    @Operation(summary = "启动数据推送")
    public R<?> startDataPush(){
        return feignClient.startDataPush();
    }

    @PostMapping("/sse/stop-push")
    @Operation(summary = "停止数据推送")
    public R<?> stopDataPush(){
        return feignClient.stopDataPush();
    }

    @GetMapping("/sse/connections")
    @Operation(summary = "获取当前SSE连接数")
    public R<Map<String, Object>> getConnections(){
        return feignClient.getConnections();
    }

    @PostMapping("/sse/push-now")
    @Operation(summary = "手动触发数据推送")
    public R<?> pushDataNow(){
        return feignClient.pushDataNow();
    }

    @GetMapping("/overview")
    @Operation(summary = "获取平台统计概览")
    public R<Map<String, Object>> getOverview(){
        return feignClient.getOverview();
    }

    @GetMapping("/area-statistics")
    @Operation(summary = "获取各街道镇区林地面积数据")
    public R<List<Map<String, Object>>> getAreaStatistics(){
        return feignClient.getAreaStatistics();
    }

    @GetMapping("/trade-statistics")
    @Operation(summary = "获取各镇区街道林地交易情况")
    public R<List<Map<String, Object>>> getTradeStatistics(){
        return feignClient.getTradeStatistics();
    }

    @GetMapping("/revenue-statistics")
    @Operation(summary = "获取资金营收统计")
    public R<List<Map<String, Object>>> getRevenueStatistics(){
        return feignClient.getRevenueStatistics();
    }

    @GetMapping("/map-data")
    @Operation(summary = "获取地图数据")
    public R<List<Map<String, Object>>> getMapData(){
        return feignClient.getMapData();
    }

    @GetMapping("/subsidy-statistics")
    @Operation(summary = "获取林地补贴申请统计")
    public R<List<Map<String, Object>>> getSubsidyStatistics(){
        return feignClient.getSubsidyStatistics();
    }

    @GetMapping("/company-statistics")
    @Operation(summary = "获取企业信息注册统计")
    public R<List<Map<String, Object>>> getCompanyStatistics(){
        return feignClient.getCompanyStatistics();
    }

    @GetMapping("/order-statistics")
    @Operation(summary = "获取交易订单统计")
    public R<Map<String, Object>> getOrderStatistics(){
        return feignClient.getOrderStatistics();
    }
}
